package com.mingweicai.intergration.test;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
public class ConfigQueueConsumer implements InitializingBean {

  @Autowired
  @Qualifier("meter")
  private MeterRegistry meterRegistry;

  @Override
  public void afterPropertiesSet() throws Exception {
    new Thread(() -> {
      while(true){
        try {
          Counter counter1 = meterRegistry.counter("eric_nef_nnef_eventexposure_overload_unsuccessful_responses_sent_total");
          counter1.increment();
          Counter counter2 = meterRegistry.counter("eric_nef_namf_eventexposure_overload_unsuccessful_responses_sent_total");
          counter2.increment();
          Counter counter3 = meterRegistry.counter("eric_nef_nudm_eventexposure_overload_unsuccessful_responses_sent_total");
          counter3.increment();
          System.out.println("sleep");
          Thread.sleep(500);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
      }
    }).start();
  }
}
